package com.lianzhihui.romeex.utils;

import android.content.Context;

import com.lianzhihui.romeex.R;
import com.lianzhihui.romeex.bean.TradeRecordBean;
import com.lianzhihui.romeex.bean.WalletMainBean;
import com.lianzhihui.romeex.config.AppConstants;

import javax.annotation.Nonnull;

/**
 * Description:
 * Author: RAMON
 * CreateDate: 11/17/20 8:55 PM
 * UpdateUser:
 * UpdateDate:
 * UpdateRemark:
 * Version:
 */
public class CoinUtils {


    public static int getTransactionTypeIcon(TradeRecordBean.DetailBean bean) {

        //“1”,转账
        //“2”,交易所充值
        //“3”,头矿奖励
        //“4”,跨链交易
        //“5”,退款（不用判断isOut）
        //“6”,手续费（不用判断isOut）
        //“7”,兑换（不判断isOut）
        //“8”,质押（不判断isOut）
        //“9”,提取（不判断isOut）
        //“10”,划转(不判断isOut)
        //“100”,其他

        switch (bean.getTransactionType()) {
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
                return getIcon(bean.getCoinName());
            case 7:
                return R.drawable.icon_exchange_h;
            case 8:
                return R.drawable.icon_pledge;
            case 9:
                return R.drawable.icon_extract;
            case 10:
                return getIcon(bean.getCoinName());
            case 100:
                return R.drawable.def_coin_icon;
            case 13:
                return getIcon(bean.getCoinName());
        }
        return R.drawable.def_coin_icon;
    }

    /**
     * 通过 coinname 获取对应图标
     *
     * @param coinName
     * @return
     */
    public static int getIcon(String coinName) {
        if (coinName.equals("REX")) {
            return R.mipmap.icon_rex_40;
        }
        if (coinName.equals("XUSD")) {
            return R.mipmap.icon_rusd_40;
        }
        if (coinName.equals("USDT")) {
            return R.drawable.icon_usdt;
        }
        return 0;
    }


    /**
     * 通过别名找实体类
     *
     * @param cobo
     * @return
     */
    public static WalletMainBean.CoinBean getCoinByAlias(@Nonnull String cobo) {

        for (int i = 0; i < AppConstants.System.coins.size(); i++) {
            if (cobo.equals(AppConstants.System.coins.get(i).getCoinNameAlias())) {
                return AppConstants.System.coins.get(i);
            }
        }
        return null;
    }

    /**
     * 获取默认 币种
     *
     * @return
     */
    public static WalletMainBean.CoinBean getDefCoin() {
//        return getCoinByAlias("USDT(ERC20)");
//        return getCoinByAlias("REX");
        return getCoinByAlias("USDT(TRC20)");
    }

}
